package jdbc;

import java.sql.Connection;
import java.sql.PreparedStatement;

public class JDBCDemo9 {
    public static void main(String[] args) {
        try (Connection conn = DBUtil.getConnection();) {
            String sql="UPDATE user " +
                    "SET password=?,phone=?,address=? " +
                    "WHERE id=? ";
            PreparedStatement pstmt = conn.prepareStatement(sql);
            pstmt.setString(1, "123456");
            pstmt.setString(2, "12345678901");
            pstmt.setString(3, "北京");
            pstmt.setInt(4, 1);
            int count = pstmt.executeUpdate();
            System.out.println(count>0?"修改成功":"修改失败");

            conn.commit();
            System.out.println("提交成功");
        }
        catch (Exception e) {
            e.printStackTrace();
        }
    }
}
